package com.project.common.utils;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

public class JWTUtil {

    //object 需要替换成对应的bean
    public static String getToken(Object object){
        String key = "by123";
        JwtBuilder jwtBuilder = Jwts.builder()
                //之后添加用于生成token的变量
                //.setId(object.getId()+"")
                //.setSubject(object.getUsername())
                .setIssuedAt(new Date())
                .signWith(SignatureAlgorithm.HS256, key);
        System.out.println(jwtBuilder.compact());
        return jwtBuilder.compact();
    }
}
